<?php

class LoginAction extends Action
{
    private $_description = array('-1'=>'账号不存在', '-2'=> '密码错误', '1'=>'登录成功');
    
    
    
    
    
	public function _onLogin(){
		$_model = D('User');
		# $_key_arr = array('u_name','u_mobile');
		$_key = $_REQUEST['type'] ? $_REQUEST['type'] : 'u_name';
		$_pwd = md5($_REQUEST['u_password']);
		$_udata[$_key] = $_REQUEST[$_key];
		
		$info = $_model->where($_udata)->find();
		if(!$info){
			$_rdata = array('status' => -1, 'msg'=>$this->_description[-1]);
		}else{
			if($_pwd != $info['u_password']){
				$_rdata = array('status' => -2, 'msg'=>$this->_description[-2]);
			}else{
				update_cookie($info);
				update_session($info);
				$_rdata = array('status' => 1, 'msg'=>$this->_description[1]);
			}
		}
		return $_rdata;
	}
	
	
}
?>